{namespace vh=In2code\Powermail\ViewHelpers}
<f:layout name="Default"/>

Render Powermail_Frontend List View
{mails}            Mail Objects


<f:section name="main">
    <f:flashMessages class="powermail_message powermail_message_error list-unstyled"/>

    <div class="panel panel-default">

        <div class="panel-heading">
            <div class="row">
                <div class="col-lg-4 col-md-4 col-xs-7">
                    <f:render partial="Output/Export" arguments="{_all}"/>
                </div>
                <div class="col-lg-6 col-md-2 col-xs-0"></div>
                <div class="col-lg-2 col-md-6 col-xs-5 text-right">
                    <f:render partial="Output/Search" arguments="{_all}"/>
                </div>
            </div>
        </div>

        <f:if condition="{mails}">
            <f:then>
                <div class="panel-body table-responsive">
                    <table class="table table-hover">
                        <f:for each="{mails}" as="mail" iteration="index">

                            <f:if condition="{index.isFirst}">
                                <tr>
                                    <th>ID</th>
                                    <f:for each="{fields}" as="field">
                                        <th class="powermail_sorting">
                                            {field.title}
                                        </th>
                                    </f:for>
                                    <th></th>
                                </tr>
                            </f:if>

                            <tr>
                                <td><span title="{mail.uid}">{mail.uid}</span></td>
                                <f:for each="{fields}" as="field">
                                    <td>
                                        <f:for each="{mail.answers}" as="answer">
                                            <f:if condition="{answer.field} == {field}">

                                                <f:comment>Data Type String</f:comment>
                                                <f:if condition="{answer.valueType} == 0">
                                                    <f:format.nl2br>{answer.value}</f:format.nl2br>
                                                </f:if>

                                                <f:comment>Data Type Array</f:comment>
                                                <f:if condition="{answer.valueType} == 1">
                                                    <vh:String.ImplodeField objects="{answer.value}" separator=", "/>
                                                </f:if>

                                                <f:comment>Data Type Date (already parsed Timestamp by Model)</f:comment>
                                                <f:if condition="{answer.valueType} == 2">
                                                    {answer.value}
                                                </f:if>

                                                <f:comment>Data Type Fileupload</f:comment>
                                                <f:if condition="{answer.valueType} == 3">
                                                    <f:for each="{answer.value}" as="subValue" iteration="uploadIndex">
                                                        <f:link.page pageUid="{settings.misc.file.folder}{subValue}" target="_blank">
                                                            <f:if condition="{vh:Condition.IsImage(path:subValue)}">
                                                                <f:then>
                                                                    <f:if condition="{vh:Condition.FileExists(file:'{settings.misc.file.folder}{subValue}')}">
                                                                        <f:then>
                                                                            <f:image src="{settings.misc.file.folder}{subValue}" alt="{subValue}" width="200" maxHeight="200"/>
                                                                        </f:then>
                                                                        <f:else>
                                                                            File does not exist
                                                                        </f:else>
                                                                    </f:if>
                                                                </f:then>
                                                                <f:else>
                                                                    {subValue}
                                                                </f:else>
                                                            </f:if>
                                                        </f:link.page>
                                                        <br/>
                                                    </f:for>
                                                </f:if>
                                            </f:if>
                                        </f:for>
                                    </td>
                                </f:for>
                                <td>
                                    <f:if condition="{settings.single.activateLink}">
                                        <f:link.action action="show" pageUid="{singlePid}" arguments="{mail:mail}" class="btn btn-info btn-xs">
                                            <f:translate key="PowermailFrontendDetailView">查看</f:translate>
                                        </f:link.action>
                                    </f:if>

                                    <f:if condition="{vh:Condition.IsAllowedToEdit(settings:settings, mail:mail)}">
                                        <f:link.action action="edit" pageUid="{editPid}" arguments="{mail:mail}" class="btn btn-info btn-xs">
                                            <f:translate key="PowermailFrontendEditView">编辑</f:translate>
                                        </f:link.action>
                                    </f:if>

                                    <f:if condition="{vh:Condition.IsAllowedToEdit(settings:settings, mail:mail)}">
                                        <f:link.action action="delete" pageUid="{editPid}" arguments="{mail:mail}" class="btn btn-danger btn-xs" onclick="return confirm('确定删除?');">
                                            <f:translate key="PowermailFrontendDeleteView">删除</f:translate>
                                        </f:link.action>
                                    </f:if>
                                </td>
                            </tr>

                        </f:for>
                    </table>
                </div>
            </f:then>
            <f:else>
                <div class="panel-body">
                    <f:translate key="BackendListNoMails"/>
                </div>
            </f:else>
        </f:if>

    </div>
</f:section>
